﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
using LevelEditor.Objects;
using LevelEditor.Dao;

namespace LevelEditor.Objects.Tiles
{
    class Item : Tile
    {
        public enum Variables
        {
            PositionX, PositionY, MyTrigger, StandAloneBehavior,
        }

        public Item(LevelEditor editor)  : base(editor)
        {
            this.myType = TileType.Item;
        }

        public override void Deselect()
        {
            base.Deselect();
            editor.propertiesPanel1.HideProperties(this);
        }

        protected override void Tile_MouseMove(object sender, MouseEventArgs e)
        {
            base.Tile_MouseMove(sender, e);

        }

        protected override void Tile_MouseUp(object sender, MouseEventArgs e)
        {
            base.Tile_MouseUp(sender, e);

            if (Tile.CurrentSelectedTile != null)
                editor.propertiesPanel1.Refresh();
        }

        public void PositionXChanged(object sender, EventArgs args)
        {
            if (((TextBox)sender).Text == "") return;


            Point p = Point.Empty;
            try
            {
                p = new Point(int.Parse(((TextBox)sender).Text), this.Location.Y);
            }
            catch (FormatException)
            {
            }
            this.Location = p;

            this.Father.Tile.Location = p;
        }

        public void PositionYChanged(object sender, EventArgs args)
        {
            if (((TextBox)sender).Text == "") return;

            Point p = new Point(this.Location.X, int.Parse(((TextBox)sender).Text));
            this.Location = p;

            this.Father.Tile.Location = p;
        }

    }
}
